package com.dmc.scrabblator;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import com.dmc.scrabblator.structures.CharVal;

public class WordValue implements Comparable<WordValue>
{
    private List<CharVal> word;

    private int value;

    private boolean blank = false;//

    public WordValue(List<CharVal> word, int value)
    {
        super();
        this.word = new ArrayList<CharVal>(word);
        
        this.value = value;
    }

    /**
     * @return the word
     */
    public List<CharVal> getWord()
    {
        return word;
    }

    /**
     * @param word the word to set
     */
    public void setWord(List<CharVal> word)
    {
        this.word = word;
    }

    /**
     * @return the value
     */
    public int getValue()
    {
        return value;
    }

    /**
     * @param value the value to set
     */
    public void setValue(int value)
    {
        this.value = value;
    }

    public String getString()
    {
        StringBuilder s = new StringBuilder();
        for (CharVal c : word)
            s.append(c.getChar());
        return s.toString();
    }

    //@Override
    public int compareTo(WordValue o)
    {
        if (this.value != o.getValue())
            return o.getValue() - this.value;

        return this.getString().compareTo(o.getString());
    }

    /* (non-Javadoc)
     * @see java.lang.Object#toString()
     */
    public String toString()
    {
        return this.getString() + " \t" + this.value;
    }

    /**
     * @return the blank
     */
    public boolean isBlank()
    {
        return blank;
    }

    /**
     * @param blank the blank to set
     */
    public void setBlank(boolean blank)
    {
        this.blank = blank;
    }

}
